package com.drinks.yiniang.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.drinks.yiniang.App;

/**
 * Created by Administrator on 2017/3/25 0025.
 */
public class VersionUtils {

    public static String versionCode;

    //版本名
    public static String getVersionName() {
        return getPackageInfo().versionName;
    }

    //版本号
    public static int getVersionCode() {
        return getPackageInfo().versionCode;
    }

    private static PackageInfo getPackageInfo() {
        PackageInfo pi = null;

        try {
            PackageManager pm = App.getInstance().getApplicationContext().getPackageManager();
            pi = pm.getPackageInfo(App.getInstance().getApplicationContext().getPackageName(),
                    PackageManager.GET_CONFIGURATIONS);

            return pi;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return pi;
    }
}
